# -*- coding: utf-8 -*-
"""
    测试&示范使用代码
"""
import random
import jpegio as jio
from  hide import imbed
from extrac import extra
import trans


if __name__=="__main__":
    path="image/5.1.11.jpg"
    message="hello word!"
    message=trans.Str_encode(message)
    output="hide.jpg"
    jpeg=jio.read(path)
    # 隐藏信息
    key,jpeg=imbed(jpeg,message)
    jio.write(jpeg,output)
    # 提取
    print("生成解密key： {}".format(key))
    print("含水印文件已保存在文件: "+output)
    jpeg=jio.read(output)
    print("提取出的消息: "+trans.Str_decode(extra(jpeg,key,len(message))))
